<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../vue.js"></script>
</head>

<body>
    <div class="box">

        <wzp @enlarge-text='handle($event)'></wzp>
        <div :style="{fontSize: fontSize + 'px'}">{{name}}</div>
    </div>
    <script>
        Vue.component('wzp', {
            data: function() {
                return {
                    name: '子组件内容'
                }
            },
            template: `
            <div>
                <p> {{ name }} </p>   
                <button @click='$emit("enlarge-text",50)'>字体变大</button> 
            </div>
            `
        })
        var vm = new Vue({
            el: '.box',
            data: {
                name: '父组件内容',
                fontSize: 15,
                num: 12,
            },
            methods: {
                handle($event) {
                    this.fontSize += $event
                    console.log(this.num)
                }
            }
        })
    </script>
</body>

</html>